
user/_btreetest:     file format elf64-littleriscv


Disassembly of section .text:

0000000000000000 <itoa>:
#include "kernel/fcntl.h"
#include "kernel/fs.h"
#include "kernel/btree.h"

void
itoa(int num, char* str) {
   0:	1141                	addi	sp,sp,-16
   2:	e422                	sd	s0,8(sp)
   4:	0800                	addi	s0,sp,16
    int i = 0;
    int isNegative = 0;

    // 处理负数
    if (num < 0) {
   6:	00054a63          	bltz	a0,1a <itoa+0x1a>
        isNegative = 1;
        num = -num;
    }

    // 处理0的特殊情况
    if (num == 0) {
   a:	e159                	bnez	a0,90 <itoa+0x90>
        str[i++] = '0';
   c:	03000793          	li	a5,48
  10:	00f58023          	sb	a5,0(a1)
        str[i] = '\0';
  14:	000580a3          	sb	zero,1(a1)
        return;
  18:	a88d                	j	8a <itoa+0x8a>
        num = -num;
  1a:	40a0053b          	negw	a0,a0
        isNegative = 1;
  1e:	4305                	li	t1,1
    }

    // 计算数字的位数
    while (num != 0) {
  20:	86ae                	mv	a3,a1
        isNegative = 1;
  22:	862e                	mv	a2,a1
    int i = 0;
  24:	4701                	li	a4,0
        int rem = num % 10;
  26:	4829                	li	a6,10
        str[i++] = rem + '0';  // 将数字转换为字符
  28:	88ba                	mv	a7,a4
  2a:	2705                	addiw	a4,a4,1
        int rem = num % 10;
  2c:	030567bb          	remw	a5,a0,a6
        str[i++] = rem + '0';  // 将数字转换为字符
  30:	0307879b          	addiw	a5,a5,48
  34:	00f60023          	sb	a5,0(a2)
        num = num / 10;
  38:	0305453b          	divw	a0,a0,a6
    while (num != 0) {
  3c:	0605                	addi	a2,a2,1
  3e:	f56d                	bnez	a0,28 <itoa+0x28>
    }

    // 如果是负数，添加负号
    if (isNegative) {
  40:	00030963          	beqz	t1,52 <itoa+0x52>
        str[i++] = '-';
  44:	972e                	add	a4,a4,a1
  46:	02d00793          	li	a5,45
  4a:	00f70023          	sb	a5,0(a4)
  4e:	0028871b          	addiw	a4,a7,2
    }

    str[i] = '\0';  // 添加字符串结束符
  52:	00e587b3          	add	a5,a1,a4
  56:	00078023          	sb	zero,0(a5)

    // 反转字符串
    int start = 0;
    int end = i - 1;
  5a:	fff7079b          	addiw	a5,a4,-1
    while (start < end) {
  5e:	02f05663          	blez	a5,8a <itoa+0x8a>
  62:	95be                	add	a1,a1,a5
        char temp = str[start];
  64:	0006c783          	lbu	a5,0(a3)
        str[start] = str[end];
  68:	0005c603          	lbu	a2,0(a1)
  6c:	00c68023          	sb	a2,0(a3)
        str[end] = temp;
  70:	00f58023          	sb	a5,0(a1)
        start++;
  74:	0015079b          	addiw	a5,a0,1
  78:	0007851b          	sext.w	a0,a5
    while (start < end) {
  7c:	0685                	addi	a3,a3,1
  7e:	15fd                	addi	a1,a1,-1
  80:	40f707bb          	subw	a5,a4,a5
  84:	37fd                	addiw	a5,a5,-1
  86:	fcf54fe3          	blt	a0,a5,64 <itoa+0x64>
        end--;
    }
}
  8a:	6422                	ld	s0,8(sp)
  8c:	0141                	addi	sp,sp,16
  8e:	8082                	ret
    int isNegative = 0;
  90:	4301                	li	t1,0
  92:	b779                	j	20 <itoa+0x20>

0000000000000094 <printbtn>:

void
printbtn(int fd, struct btreenode *btn){
  94:	bc010113          	addi	sp,sp,-1088
  98:	42113c23          	sd	ra,1080(sp)
  9c:	42813823          	sd	s0,1072(sp)
  a0:	42913423          	sd	s1,1064(sp)
  a4:	43213023          	sd	s2,1056(sp)
  a8:	41313c23          	sd	s3,1048(sp)
  ac:	41413823          	sd	s4,1040(sp)
  b0:	41513423          	sd	s5,1032(sp)
  b4:	44010413          	addi	s0,sp,1088
  b8:	89aa                	mv	s3,a0
  ba:	892e                	mv	s2,a1
  printf("%d block btreenode start\n", btn->block);
  bc:	3f85a583          	lw	a1,1016(a1)
  c0:	00001517          	auipc	a0,0x1
  c4:	c8850513          	addi	a0,a0,-888 # d48 <malloc+0xec>
  c8:	00001097          	auipc	ra,0x1
  cc:	adc080e7          	jalr	-1316(ra) # ba4 <printf>
  for(int i = 0; i < btn->numkeys; i++){
  d0:	00492783          	lw	a5,4(s2)
  d4:	c79d                	beqz	a5,102 <printbtn+0x6e>
  d6:	00e90493          	addi	s1,s2,14
  da:	4a01                	li	s4,0
    printf("%s ", btn->keys[i].name);
  dc:	00001a97          	auipc	s5,0x1
  e0:	c8ca8a93          	addi	s5,s5,-884 # d68 <malloc+0x10c>
  e4:	85a6                	mv	a1,s1
  e6:	8556                	mv	a0,s5
  e8:	00001097          	auipc	ra,0x1
  ec:	abc080e7          	jalr	-1348(ra) # ba4 <printf>
  for(int i = 0; i < btn->numkeys; i++){
  f0:	001a079b          	addiw	a5,s4,1
  f4:	00078a1b          	sext.w	s4,a5
  f8:	04c1                	addi	s1,s1,16
  fa:	00492703          	lw	a4,4(s2)
  fe:	feea63e3          	bltu	s4,a4,e4 <printbtn+0x50>
  }
  printf("\n%d block btreenode over\n", btn->block);
 102:	3f892583          	lw	a1,1016(s2)
 106:	00001517          	auipc	a0,0x1
 10a:	c6a50513          	addi	a0,a0,-918 # d70 <malloc+0x114>
 10e:	00001097          	auipc	ra,0x1
 112:	a96080e7          	jalr	-1386(ra) # ba4 <printf>
  for(int i = 0; i < btn->childnum; i++){
 116:	00892783          	lw	a5,8(s2)
 11a:	cf9d                	beqz	a5,158 <printbtn+0xc4>
 11c:	32c90493          	addi	s1,s2,812
 120:	4a01                	li	s4,0
    if(btn->children[i] == 0){
 122:	4094                	lw	a3,0(s1)
 124:	cab9                	beqz	a3,17a <printbtn+0xe6>
      printf("btree readdir failed\n");
      close(fd);
      exit(1);
    }
    struct btreenode newbtn;
    rbtn(fd, &newbtn, sizeof(struct btreenode), btn->children[i]);
 126:	3fc00613          	li	a2,1020
 12a:	bc040593          	addi	a1,s0,-1088
 12e:	854e                	mv	a0,s3
 130:	00000097          	auipc	ra,0x0
 134:	792080e7          	jalr	1938(ra) # 8c2 <rbtn>
    printbtn(fd, &newbtn);
 138:	bc040593          	addi	a1,s0,-1088
 13c:	854e                	mv	a0,s3
 13e:	00000097          	auipc	ra,0x0
 142:	f56080e7          	jalr	-170(ra) # 94 <printbtn>
  for(int i = 0; i < btn->childnum; i++){
 146:	001a079b          	addiw	a5,s4,1
 14a:	00078a1b          	sext.w	s4,a5
 14e:	0491                	addi	s1,s1,4
 150:	00892703          	lw	a4,8(s2)
 154:	fcea67e3          	bltu	s4,a4,122 <printbtn+0x8e>
  }
}
 158:	43813083          	ld	ra,1080(sp)
 15c:	43013403          	ld	s0,1072(sp)
 160:	42813483          	ld	s1,1064(sp)
 164:	42013903          	ld	s2,1056(sp)
 168:	41813983          	ld	s3,1048(sp)
 16c:	41013a03          	ld	s4,1040(sp)
 170:	40813a83          	ld	s5,1032(sp)
 174:	44010113          	addi	sp,sp,1088
 178:	8082                	ret
      printf("btree readdir failed\n");
 17a:	00001517          	auipc	a0,0x1
 17e:	c1650513          	addi	a0,a0,-1002 # d90 <malloc+0x134>
 182:	00001097          	auipc	ra,0x1
 186:	a22080e7          	jalr	-1502(ra) # ba4 <printf>
      close(fd);
 18a:	854e                	mv	a0,s3
 18c:	00000097          	auipc	ra,0x0
 190:	6be080e7          	jalr	1726(ra) # 84a <close>
      exit(1);
 194:	4505                	li	a0,1
 196:	00000097          	auipc	ra,0x0
 19a:	68c080e7          	jalr	1676(ra) # 822 <exit>

000000000000019e <dirtest>:

void dirtest(){
 19e:	1141                	addi	sp,sp,-16
 1a0:	e406                	sd	ra,8(sp)
 1a2:	e022                	sd	s0,0(sp)
 1a4:	0800                	addi	s0,sp,16
  if(mkdir("dir0") < 0){
 1a6:	00001517          	auipc	a0,0x1
 1aa:	c0250513          	addi	a0,a0,-1022 # da8 <malloc+0x14c>
 1ae:	00000097          	auipc	ra,0x0
 1b2:	6dc080e7          	jalr	1756(ra) # 88a <mkdir>
 1b6:	02054a63          	bltz	a0,1ea <dirtest+0x4c>
    printf("mkdir failed\n");
    exit(1);
  }

  if(chdir("dir0") < 0){
 1ba:	00001517          	auipc	a0,0x1
 1be:	bee50513          	addi	a0,a0,-1042 # da8 <malloc+0x14c>
 1c2:	00000097          	auipc	ra,0x0
 1c6:	6d0080e7          	jalr	1744(ra) # 892 <chdir>
 1ca:	02054d63          	bltz	a0,204 <dirtest+0x66>
    printf("chdir dir0 failed\n");
    exit(1);
  }

  if(chdir("..") < 0){
 1ce:	00001517          	auipc	a0,0x1
 1d2:	c0a50513          	addi	a0,a0,-1014 # dd8 <malloc+0x17c>
 1d6:	00000097          	auipc	ra,0x0
 1da:	6bc080e7          	jalr	1724(ra) # 892 <chdir>
 1de:	04054063          	bltz	a0,21e <dirtest+0x80>
    printf("chdir .. failed\n");
    exit(1);
  }
}
 1e2:	60a2                	ld	ra,8(sp)
 1e4:	6402                	ld	s0,0(sp)
 1e6:	0141                	addi	sp,sp,16
 1e8:	8082                	ret
    printf("mkdir failed\n");
 1ea:	00001517          	auipc	a0,0x1
 1ee:	bc650513          	addi	a0,a0,-1082 # db0 <malloc+0x154>
 1f2:	00001097          	auipc	ra,0x1
 1f6:	9b2080e7          	jalr	-1614(ra) # ba4 <printf>
    exit(1);
 1fa:	4505                	li	a0,1
 1fc:	00000097          	auipc	ra,0x0
 200:	626080e7          	jalr	1574(ra) # 822 <exit>
    printf("chdir dir0 failed\n");
 204:	00001517          	auipc	a0,0x1
 208:	bbc50513          	addi	a0,a0,-1092 # dc0 <malloc+0x164>
 20c:	00001097          	auipc	ra,0x1
 210:	998080e7          	jalr	-1640(ra) # ba4 <printf>
    exit(1);
 214:	4505                	li	a0,1
 216:	00000097          	auipc	ra,0x0
 21a:	60c080e7          	jalr	1548(ra) # 822 <exit>
    printf("chdir .. failed\n");
 21e:	00001517          	auipc	a0,0x1
 222:	bc250513          	addi	a0,a0,-1086 # de0 <malloc+0x184>
 226:	00001097          	auipc	ra,0x1
 22a:	97e080e7          	jalr	-1666(ra) # ba4 <printf>
    exit(1);
 22e:	4505                	li	a0,1
 230:	00000097          	auipc	ra,0x0
 234:	5f2080e7          	jalr	1522(ra) # 822 <exit>

0000000000000238 <dirfile>:

void dirfile(){
 238:	1101                	addi	sp,sp,-32
 23a:	ec06                	sd	ra,24(sp)
 23c:	e822                	sd	s0,16(sp)
 23e:	e426                	sd	s1,8(sp)
 240:	1000                	addi	s0,sp,32
  int fd;
  fd = open("dirfile", O_CREATE);
 242:	20000593          	li	a1,512
 246:	00001517          	auipc	a0,0x1
 24a:	bb250513          	addi	a0,a0,-1102 # df8 <malloc+0x19c>
 24e:	00000097          	auipc	ra,0x0
 252:	614080e7          	jalr	1556(ra) # 862 <open>
  if(fd < 0){
 256:	0a054963          	bltz	a0,308 <dirfile+0xd0>
    printf("create dirfile failed\n");
    exit(1);
  }
  close(fd);
 25a:	00000097          	auipc	ra,0x0
 25e:	5f0080e7          	jalr	1520(ra) # 84a <close>
  if(chdir("dirfile") == 0){
 262:	00001517          	auipc	a0,0x1
 266:	b9650513          	addi	a0,a0,-1130 # df8 <malloc+0x19c>
 26a:	00000097          	auipc	ra,0x0
 26e:	628080e7          	jalr	1576(ra) # 892 <chdir>
 272:	c945                	beqz	a0,322 <dirfile+0xea>
    printf("chdir dirfile succeeded!\n");
    exit(1);
  }
  fd = open("dirfile/xx", 0);
 274:	4581                	li	a1,0
 276:	00001517          	auipc	a0,0x1
 27a:	bc250513          	addi	a0,a0,-1086 # e38 <malloc+0x1dc>
 27e:	00000097          	auipc	ra,0x0
 282:	5e4080e7          	jalr	1508(ra) # 862 <open>
  if(fd >= 0){
 286:	0a055b63          	bgez	a0,33c <dirfile+0x104>
    printf("create dirfile/xx succeeded!\n");
    exit(1);
  }
  fd = open("dirfile/xx", O_CREATE);
 28a:	20000593          	li	a1,512
 28e:	00001517          	auipc	a0,0x1
 292:	baa50513          	addi	a0,a0,-1110 # e38 <malloc+0x1dc>
 296:	00000097          	auipc	ra,0x0
 29a:	5cc080e7          	jalr	1484(ra) # 862 <open>
  if(fd >= 0){
 29e:	0a055c63          	bgez	a0,356 <dirfile+0x11e>
    printf("create dirfile/xx succeeded!\n");
    exit(1);
  }
  if(mkdir("dirfile/xx") == 0){
 2a2:	00001517          	auipc	a0,0x1
 2a6:	b9650513          	addi	a0,a0,-1130 # e38 <malloc+0x1dc>
 2aa:	00000097          	auipc	ra,0x0
 2ae:	5e0080e7          	jalr	1504(ra) # 88a <mkdir>
 2b2:	cd5d                	beqz	a0,370 <dirfile+0x138>
    printf("mkdir dirfile/xx succeeded!\n");
    exit(1);
  }

  fd = open(".", O_RDWR);
 2b4:	4589                	li	a1,2
 2b6:	00001517          	auipc	a0,0x1
 2ba:	bd250513          	addi	a0,a0,-1070 # e88 <malloc+0x22c>
 2be:	00000097          	auipc	ra,0x0
 2c2:	5a4080e7          	jalr	1444(ra) # 862 <open>
  if(fd >= 0){
 2c6:	0c055263          	bgez	a0,38a <dirfile+0x152>
    printf("open . for writing succeeded!\n");
    exit(1);
  }
  fd = open(".", 0);
 2ca:	4581                	li	a1,0
 2cc:	00001517          	auipc	a0,0x1
 2d0:	bbc50513          	addi	a0,a0,-1092 # e88 <malloc+0x22c>
 2d4:	00000097          	auipc	ra,0x0
 2d8:	58e080e7          	jalr	1422(ra) # 862 <open>
 2dc:	84aa                	mv	s1,a0
  if(write(fd, "x", 1) > 0){
 2de:	4605                	li	a2,1
 2e0:	00001597          	auipc	a1,0x1
 2e4:	bd058593          	addi	a1,a1,-1072 # eb0 <malloc+0x254>
 2e8:	00000097          	auipc	ra,0x0
 2ec:	55a080e7          	jalr	1370(ra) # 842 <write>
 2f0:	0aa04a63          	bgtz	a0,3a4 <dirfile+0x16c>
    printf("write . succeeded!\n");
    exit(1);
  }
  close(fd);
 2f4:	8526                	mv	a0,s1
 2f6:	00000097          	auipc	ra,0x0
 2fa:	554080e7          	jalr	1364(ra) # 84a <close>
}
 2fe:	60e2                	ld	ra,24(sp)
 300:	6442                	ld	s0,16(sp)
 302:	64a2                	ld	s1,8(sp)
 304:	6105                	addi	sp,sp,32
 306:	8082                	ret
    printf("create dirfile failed\n");
 308:	00001517          	auipc	a0,0x1
 30c:	af850513          	addi	a0,a0,-1288 # e00 <malloc+0x1a4>
 310:	00001097          	auipc	ra,0x1
 314:	894080e7          	jalr	-1900(ra) # ba4 <printf>
    exit(1);
 318:	4505                	li	a0,1
 31a:	00000097          	auipc	ra,0x0
 31e:	508080e7          	jalr	1288(ra) # 822 <exit>
    printf("chdir dirfile succeeded!\n");
 322:	00001517          	auipc	a0,0x1
 326:	af650513          	addi	a0,a0,-1290 # e18 <malloc+0x1bc>
 32a:	00001097          	auipc	ra,0x1
 32e:	87a080e7          	jalr	-1926(ra) # ba4 <printf>
    exit(1);
 332:	4505                	li	a0,1
 334:	00000097          	auipc	ra,0x0
 338:	4ee080e7          	jalr	1262(ra) # 822 <exit>
    printf("create dirfile/xx succeeded!\n");
 33c:	00001517          	auipc	a0,0x1
 340:	b0c50513          	addi	a0,a0,-1268 # e48 <malloc+0x1ec>
 344:	00001097          	auipc	ra,0x1
 348:	860080e7          	jalr	-1952(ra) # ba4 <printf>
    exit(1);
 34c:	4505                	li	a0,1
 34e:	00000097          	auipc	ra,0x0
 352:	4d4080e7          	jalr	1236(ra) # 822 <exit>
    printf("create dirfile/xx succeeded!\n");
 356:	00001517          	auipc	a0,0x1
 35a:	af250513          	addi	a0,a0,-1294 # e48 <malloc+0x1ec>
 35e:	00001097          	auipc	ra,0x1
 362:	846080e7          	jalr	-1978(ra) # ba4 <printf>
    exit(1);
 366:	4505                	li	a0,1
 368:	00000097          	auipc	ra,0x0
 36c:	4ba080e7          	jalr	1210(ra) # 822 <exit>
    printf("mkdir dirfile/xx succeeded!\n");
 370:	00001517          	auipc	a0,0x1
 374:	af850513          	addi	a0,a0,-1288 # e68 <malloc+0x20c>
 378:	00001097          	auipc	ra,0x1
 37c:	82c080e7          	jalr	-2004(ra) # ba4 <printf>
    exit(1);
 380:	4505                	li	a0,1
 382:	00000097          	auipc	ra,0x0
 386:	4a0080e7          	jalr	1184(ra) # 822 <exit>
    printf("open . for writing succeeded!\n");
 38a:	00001517          	auipc	a0,0x1
 38e:	b0650513          	addi	a0,a0,-1274 # e90 <malloc+0x234>
 392:	00001097          	auipc	ra,0x1
 396:	812080e7          	jalr	-2030(ra) # ba4 <printf>
    exit(1);
 39a:	4505                	li	a0,1
 39c:	00000097          	auipc	ra,0x0
 3a0:	486080e7          	jalr	1158(ra) # 822 <exit>
    printf("write . succeeded!\n");
 3a4:	00001517          	auipc	a0,0x1
 3a8:	b1450513          	addi	a0,a0,-1260 # eb8 <malloc+0x25c>
 3ac:	00000097          	auipc	ra,0x0
 3b0:	7f8080e7          	jalr	2040(ra) # ba4 <printf>
    exit(1);
 3b4:	4505                	li	a0,1
 3b6:	00000097          	auipc	ra,0x0
 3ba:	46c080e7          	jalr	1132(ra) # 822 <exit>

00000000000003be <readdir>:

void readdir(){
 3be:	9d010113          	addi	sp,sp,-1584
 3c2:	62113423          	sd	ra,1576(sp)
 3c6:	62813023          	sd	s0,1568(sp)
 3ca:	60913c23          	sd	s1,1560(sp)
 3ce:	61213823          	sd	s2,1552(sp)
 3d2:	63010413          	addi	s0,sp,1584
  // 创建0-29目录
  for(int i = 0; i < 30; i++){
 3d6:	4481                	li	s1,0
 3d8:	4979                	li	s2,30
    char dirname[DIRSIZ]; // 确保这个数组足够大以存放字符串
    itoa(i, dirname); // 将整数i格式化为字符串"dirX"
 3da:	9d040593          	addi	a1,s0,-1584
 3de:	8526                	mv	a0,s1
 3e0:	00000097          	auipc	ra,0x0
 3e4:	c20080e7          	jalr	-992(ra) # 0 <itoa>
    if(mkdir(dirname) < 0){
 3e8:	9d040513          	addi	a0,s0,-1584
 3ec:	00000097          	auipc	ra,0x0
 3f0:	49e080e7          	jalr	1182(ra) # 88a <mkdir>
 3f4:	0a054e63          	bltz	a0,4b0 <readdir+0xf2>
  for(int i = 0; i < 30; i++){
 3f8:	2485                	addiw	s1,s1,1
 3fa:	ff2490e3          	bne	s1,s2,3da <readdir+0x1c>
  char buf[512], *p;
  char *path = ".";
  struct btreenode btn;
  int fd;

  if((fd = open(path, 0)) < 0){
 3fe:	4581                	li	a1,0
 400:	00001517          	auipc	a0,0x1
 404:	a8850513          	addi	a0,a0,-1400 # e88 <malloc+0x22c>
 408:	00000097          	auipc	ra,0x0
 40c:	45a080e7          	jalr	1114(ra) # 862 <open>
 410:	84aa                	mv	s1,a0
 412:	0a054c63          	bltz	a0,4ca <readdir+0x10c>
    printf("open . for writing failed!\n");
    exit(1);
  }

  if(strlen(path) + 1 + DIRSIZ + 1 > sizeof buf){
 416:	00001517          	auipc	a0,0x1
 41a:	a7250513          	addi	a0,a0,-1422 # e88 <malloc+0x22c>
 41e:	00000097          	auipc	ra,0x0
 422:	1e0080e7          	jalr	480(ra) # 5fe <strlen>
 426:	2541                	addiw	a0,a0,16
 428:	20000793          	li	a5,512
 42c:	0aa7ec63          	bltu	a5,a0,4e4 <readdir+0x126>
    printf("path too long\n");
    close(fd);
    exit(1);
  }

  strcpy(buf, path);
 430:	00001597          	auipc	a1,0x1
 434:	a5858593          	addi	a1,a1,-1448 # e88 <malloc+0x22c>
 438:	de040513          	addi	a0,s0,-544
 43c:	00000097          	auipc	ra,0x0
 440:	17a080e7          	jalr	378(ra) # 5b6 <strcpy>
  p = buf+strlen(buf);
 444:	de040513          	addi	a0,s0,-544
 448:	00000097          	auipc	ra,0x0
 44c:	1b6080e7          	jalr	438(ra) # 5fe <strlen>
 450:	02051793          	slli	a5,a0,0x20
 454:	9381                	srli	a5,a5,0x20
  *p++ = '/';
 456:	1781                	addi	a5,a5,-32
 458:	97a2                	add	a5,a5,s0
 45a:	02f00713          	li	a4,47
 45e:	e0e78023          	sb	a4,-512(a5)

  if(read(fd, &btn, sizeof(struct btreenode)) == sizeof(struct btreenode)){
 462:	3fc00613          	li	a2,1020
 466:	9e040593          	addi	a1,s0,-1568
 46a:	8526                	mv	a0,s1
 46c:	00000097          	auipc	ra,0x0
 470:	3ce080e7          	jalr	974(ra) # 83a <read>
 474:	3fc00793          	li	a5,1020
 478:	00f51c63          	bne	a0,a5,490 <readdir+0xd2>
    if(btn.block == 0){
 47c:	dd842783          	lw	a5,-552(s0)
 480:	c7c1                	beqz	a5,508 <readdir+0x14a>
      printf("btree readdir failed\n");
      close(fd);
      exit(1);
    }
    printbtn(fd, &btn);
 482:	9e040593          	addi	a1,s0,-1568
 486:	8526                	mv	a0,s1
 488:	00000097          	auipc	ra,0x0
 48c:	c0c080e7          	jalr	-1012(ra) # 94 <printbtn>
  }
  close(fd);
 490:	8526                	mv	a0,s1
 492:	00000097          	auipc	ra,0x0
 496:	3b8080e7          	jalr	952(ra) # 84a <close>
}
 49a:	62813083          	ld	ra,1576(sp)
 49e:	62013403          	ld	s0,1568(sp)
 4a2:	61813483          	ld	s1,1560(sp)
 4a6:	61013903          	ld	s2,1552(sp)
 4aa:	63010113          	addi	sp,sp,1584
 4ae:	8082                	ret
      printf("mkdir failed\n");
 4b0:	00001517          	auipc	a0,0x1
 4b4:	90050513          	addi	a0,a0,-1792 # db0 <malloc+0x154>
 4b8:	00000097          	auipc	ra,0x0
 4bc:	6ec080e7          	jalr	1772(ra) # ba4 <printf>
      exit(1);
 4c0:	4505                	li	a0,1
 4c2:	00000097          	auipc	ra,0x0
 4c6:	360080e7          	jalr	864(ra) # 822 <exit>
    printf("open . for writing failed!\n");
 4ca:	00001517          	auipc	a0,0x1
 4ce:	a0650513          	addi	a0,a0,-1530 # ed0 <malloc+0x274>
 4d2:	00000097          	auipc	ra,0x0
 4d6:	6d2080e7          	jalr	1746(ra) # ba4 <printf>
    exit(1);
 4da:	4505                	li	a0,1
 4dc:	00000097          	auipc	ra,0x0
 4e0:	346080e7          	jalr	838(ra) # 822 <exit>
    printf("path too long\n");
 4e4:	00001517          	auipc	a0,0x1
 4e8:	a0c50513          	addi	a0,a0,-1524 # ef0 <malloc+0x294>
 4ec:	00000097          	auipc	ra,0x0
 4f0:	6b8080e7          	jalr	1720(ra) # ba4 <printf>
    close(fd);
 4f4:	8526                	mv	a0,s1
 4f6:	00000097          	auipc	ra,0x0
 4fa:	354080e7          	jalr	852(ra) # 84a <close>
    exit(1);
 4fe:	4505                	li	a0,1
 500:	00000097          	auipc	ra,0x0
 504:	322080e7          	jalr	802(ra) # 822 <exit>
      printf("btree readdir failed\n");
 508:	00001517          	auipc	a0,0x1
 50c:	88850513          	addi	a0,a0,-1912 # d90 <malloc+0x134>
 510:	00000097          	auipc	ra,0x0
 514:	694080e7          	jalr	1684(ra) # ba4 <printf>
      close(fd);
 518:	8526                	mv	a0,s1
 51a:	00000097          	auipc	ra,0x0
 51e:	330080e7          	jalr	816(ra) # 84a <close>
      exit(1);
 522:	4505                	li	a0,1
 524:	00000097          	auipc	ra,0x0
 528:	2fe080e7          	jalr	766(ra) # 822 <exit>

000000000000052c <main>:

int
main()
{
 52c:	1141                	addi	sp,sp,-16
 52e:	e406                	sd	ra,8(sp)
 530:	e022                	sd	s0,0(sp)
 532:	0800                	addi	s0,sp,16
  printf("test btree dirtest: "); 
 534:	00001517          	auipc	a0,0x1
 538:	9cc50513          	addi	a0,a0,-1588 # f00 <malloc+0x2a4>
 53c:	00000097          	auipc	ra,0x0
 540:	668080e7          	jalr	1640(ra) # ba4 <printf>
  dirtest();
 544:	00000097          	auipc	ra,0x0
 548:	c5a080e7          	jalr	-934(ra) # 19e <dirtest>
  printf("ok\n"); 
 54c:	00001517          	auipc	a0,0x1
 550:	9cc50513          	addi	a0,a0,-1588 # f18 <malloc+0x2bc>
 554:	00000097          	auipc	ra,0x0
 558:	650080e7          	jalr	1616(ra) # ba4 <printf>
  printf("test btree dirfile: "); 
 55c:	00001517          	auipc	a0,0x1
 560:	9c450513          	addi	a0,a0,-1596 # f20 <malloc+0x2c4>
 564:	00000097          	auipc	ra,0x0
 568:	640080e7          	jalr	1600(ra) # ba4 <printf>
  dirfile();
 56c:	00000097          	auipc	ra,0x0
 570:	ccc080e7          	jalr	-820(ra) # 238 <dirfile>
  printf("ok\n"); 
 574:	00001517          	auipc	a0,0x1
 578:	9a450513          	addi	a0,a0,-1628 # f18 <malloc+0x2bc>
 57c:	00000097          	auipc	ra,0x0
 580:	628080e7          	jalr	1576(ra) # ba4 <printf>
  printf("test btree readdir: \n"); 
 584:	00001517          	auipc	a0,0x1
 588:	9b450513          	addi	a0,a0,-1612 # f38 <malloc+0x2dc>
 58c:	00000097          	auipc	ra,0x0
 590:	618080e7          	jalr	1560(ra) # ba4 <printf>
  readdir();
 594:	00000097          	auipc	ra,0x0
 598:	e2a080e7          	jalr	-470(ra) # 3be <readdir>
  printf("ok\n"); 
 59c:	00001517          	auipc	a0,0x1
 5a0:	97c50513          	addi	a0,a0,-1668 # f18 <malloc+0x2bc>
 5a4:	00000097          	auipc	ra,0x0
 5a8:	600080e7          	jalr	1536(ra) # ba4 <printf>
  exit(0);
 5ac:	4501                	li	a0,0
 5ae:	00000097          	auipc	ra,0x0
 5b2:	274080e7          	jalr	628(ra) # 822 <exit>

00000000000005b6 <strcpy>:
#include "kernel/fcntl.h"
#include "user/user.h"

char*
strcpy(char *s, const char *t)
{
 5b6:	1141                	addi	sp,sp,-16
 5b8:	e422                	sd	s0,8(sp)
 5ba:	0800                	addi	s0,sp,16
  char *os;

  os = s;
  while((*s++ = *t++) != 0)
 5bc:	87aa                	mv	a5,a0
 5be:	0585                	addi	a1,a1,1
 5c0:	0785                	addi	a5,a5,1
 5c2:	fff5c703          	lbu	a4,-1(a1)
 5c6:	fee78fa3          	sb	a4,-1(a5)
 5ca:	fb75                	bnez	a4,5be <strcpy+0x8>
    ;
  return os;
}
 5cc:	6422                	ld	s0,8(sp)
 5ce:	0141                	addi	sp,sp,16
 5d0:	8082                	ret

00000000000005d2 <strcmp>:

int
strcmp(const char *p, const char *q)
{
 5d2:	1141                	addi	sp,sp,-16
 5d4:	e422                	sd	s0,8(sp)
 5d6:	0800                	addi	s0,sp,16
  while(*p && *p == *q)
 5d8:	00054783          	lbu	a5,0(a0)
 5dc:	cb91                	beqz	a5,5f0 <strcmp+0x1e>
 5de:	0005c703          	lbu	a4,0(a1)
 5e2:	00f71763          	bne	a4,a5,5f0 <strcmp+0x1e>
    p++, q++;
 5e6:	0505                	addi	a0,a0,1
 5e8:	0585                	addi	a1,a1,1
  while(*p && *p == *q)
 5ea:	00054783          	lbu	a5,0(a0)
 5ee:	fbe5                	bnez	a5,5de <strcmp+0xc>
  return (uchar)*p - (uchar)*q;
 5f0:	0005c503          	lbu	a0,0(a1)
}
 5f4:	40a7853b          	subw	a0,a5,a0
 5f8:	6422                	ld	s0,8(sp)
 5fa:	0141                	addi	sp,sp,16
 5fc:	8082                	ret

00000000000005fe <strlen>:

uint
strlen(const char *s)
{
 5fe:	1141                	addi	sp,sp,-16
 600:	e422                	sd	s0,8(sp)
 602:	0800                	addi	s0,sp,16
  int n;

  for(n = 0; s[n]; n++)
 604:	00054783          	lbu	a5,0(a0)
 608:	cf91                	beqz	a5,624 <strlen+0x26>
 60a:	0505                	addi	a0,a0,1
 60c:	87aa                	mv	a5,a0
 60e:	4685                	li	a3,1
 610:	9e89                	subw	a3,a3,a0
 612:	00f6853b          	addw	a0,a3,a5
 616:	0785                	addi	a5,a5,1
 618:	fff7c703          	lbu	a4,-1(a5)
 61c:	fb7d                	bnez	a4,612 <strlen+0x14>
    ;
  return n;
}
 61e:	6422                	ld	s0,8(sp)
 620:	0141                	addi	sp,sp,16
 622:	8082                	ret
  for(n = 0; s[n]; n++)
 624:	4501                	li	a0,0
 626:	bfe5                	j	61e <strlen+0x20>

0000000000000628 <memset>:

void*
memset(void *dst, int c, uint n)
{
 628:	1141                	addi	sp,sp,-16
 62a:	e422                	sd	s0,8(sp)
 62c:	0800                	addi	s0,sp,16
  char *cdst = (char *) dst;
  int i;
  for(i = 0; i < n; i++){
 62e:	ca19                	beqz	a2,644 <memset+0x1c>
 630:	87aa                	mv	a5,a0
 632:	1602                	slli	a2,a2,0x20
 634:	9201                	srli	a2,a2,0x20
 636:	00a60733          	add	a4,a2,a0
    cdst[i] = c;
 63a:	00b78023          	sb	a1,0(a5)
  for(i = 0; i < n; i++){
 63e:	0785                	addi	a5,a5,1
 640:	fee79de3          	bne	a5,a4,63a <memset+0x12>
  }
  return dst;
}
 644:	6422                	ld	s0,8(sp)
 646:	0141                	addi	sp,sp,16
 648:	8082                	ret

000000000000064a <strchr>:

char*
strchr(const char *s, char c)
{
 64a:	1141                	addi	sp,sp,-16
 64c:	e422                	sd	s0,8(sp)
 64e:	0800                	addi	s0,sp,16
  for(; *s; s++)
 650:	00054783          	lbu	a5,0(a0)
 654:	cb99                	beqz	a5,66a <strchr+0x20>
    if(*s == c)
 656:	00f58763          	beq	a1,a5,664 <strchr+0x1a>
  for(; *s; s++)
 65a:	0505                	addi	a0,a0,1
 65c:	00054783          	lbu	a5,0(a0)
 660:	fbfd                	bnez	a5,656 <strchr+0xc>
      return (char*)s;
  return 0;
 662:	4501                	li	a0,0
}
 664:	6422                	ld	s0,8(sp)
 666:	0141                	addi	sp,sp,16
 668:	8082                	ret
  return 0;
 66a:	4501                	li	a0,0
 66c:	bfe5                	j	664 <strchr+0x1a>

000000000000066e <gets>:

char*
gets(char *buf, int max)
{
 66e:	711d                	addi	sp,sp,-96
 670:	ec86                	sd	ra,88(sp)
 672:	e8a2                	sd	s0,80(sp)
 674:	e4a6                	sd	s1,72(sp)
 676:	e0ca                	sd	s2,64(sp)
 678:	fc4e                	sd	s3,56(sp)
 67a:	f852                	sd	s4,48(sp)
 67c:	f456                	sd	s5,40(sp)
 67e:	f05a                	sd	s6,32(sp)
 680:	ec5e                	sd	s7,24(sp)
 682:	1080                	addi	s0,sp,96
 684:	8baa                	mv	s7,a0
 686:	8a2e                	mv	s4,a1
  int i, cc;
  char c;

  for(i=0; i+1 < max; ){
 688:	892a                	mv	s2,a0
 68a:	4481                	li	s1,0
    cc = read(0, &c, 1);
    if(cc < 1)
      break;
    buf[i++] = c;
    if(c == '\n' || c == '\r')
 68c:	4aa9                	li	s5,10
 68e:	4b35                	li	s6,13
  for(i=0; i+1 < max; ){
 690:	89a6                	mv	s3,s1
 692:	2485                	addiw	s1,s1,1
 694:	0344d863          	bge	s1,s4,6c4 <gets+0x56>
    cc = read(0, &c, 1);
 698:	4605                	li	a2,1
 69a:	faf40593          	addi	a1,s0,-81
 69e:	4501                	li	a0,0
 6a0:	00000097          	auipc	ra,0x0
 6a4:	19a080e7          	jalr	410(ra) # 83a <read>
    if(cc < 1)
 6a8:	00a05e63          	blez	a0,6c4 <gets+0x56>
    buf[i++] = c;
 6ac:	faf44783          	lbu	a5,-81(s0)
 6b0:	00f90023          	sb	a5,0(s2)
    if(c == '\n' || c == '\r')
 6b4:	01578763          	beq	a5,s5,6c2 <gets+0x54>
 6b8:	0905                	addi	s2,s2,1
 6ba:	fd679be3          	bne	a5,s6,690 <gets+0x22>
  for(i=0; i+1 < max; ){
 6be:	89a6                	mv	s3,s1
 6c0:	a011                	j	6c4 <gets+0x56>
 6c2:	89a6                	mv	s3,s1
      break;
  }
  buf[i] = '\0';
 6c4:	99de                	add	s3,s3,s7
 6c6:	00098023          	sb	zero,0(s3)
  return buf;
}
 6ca:	855e                	mv	a0,s7
 6cc:	60e6                	ld	ra,88(sp)
 6ce:	6446                	ld	s0,80(sp)
 6d0:	64a6                	ld	s1,72(sp)
 6d2:	6906                	ld	s2,64(sp)
 6d4:	79e2                	ld	s3,56(sp)
 6d6:	7a42                	ld	s4,48(sp)
 6d8:	7aa2                	ld	s5,40(sp)
 6da:	7b02                	ld	s6,32(sp)
 6dc:	6be2                	ld	s7,24(sp)
 6de:	6125                	addi	sp,sp,96
 6e0:	8082                	ret

00000000000006e2 <stat>:

int
stat(const char *n, struct stat *st)
{
 6e2:	1101                	addi	sp,sp,-32
 6e4:	ec06                	sd	ra,24(sp)
 6e6:	e822                	sd	s0,16(sp)
 6e8:	e426                	sd	s1,8(sp)
 6ea:	e04a                	sd	s2,0(sp)
 6ec:	1000                	addi	s0,sp,32
 6ee:	892e                	mv	s2,a1
  int fd;
  int r;

  fd = open(n, O_RDONLY);
 6f0:	4581                	li	a1,0
 6f2:	00000097          	auipc	ra,0x0
 6f6:	170080e7          	jalr	368(ra) # 862 <open>
  if(fd < 0)
 6fa:	02054563          	bltz	a0,724 <stat+0x42>
 6fe:	84aa                	mv	s1,a0
    return -1;
  r = fstat(fd, st);
 700:	85ca                	mv	a1,s2
 702:	00000097          	auipc	ra,0x0
 706:	178080e7          	jalr	376(ra) # 87a <fstat>
 70a:	892a                	mv	s2,a0
  close(fd);
 70c:	8526                	mv	a0,s1
 70e:	00000097          	auipc	ra,0x0
 712:	13c080e7          	jalr	316(ra) # 84a <close>
  return r;
}
 716:	854a                	mv	a0,s2
 718:	60e2                	ld	ra,24(sp)
 71a:	6442                	ld	s0,16(sp)
 71c:	64a2                	ld	s1,8(sp)
 71e:	6902                	ld	s2,0(sp)
 720:	6105                	addi	sp,sp,32
 722:	8082                	ret
    return -1;
 724:	597d                	li	s2,-1
 726:	bfc5                	j	716 <stat+0x34>

0000000000000728 <atoi>:

int
atoi(const char *s)
{
 728:	1141                	addi	sp,sp,-16
 72a:	e422                	sd	s0,8(sp)
 72c:	0800                	addi	s0,sp,16
  int n;

  n = 0;
  while('0' <= *s && *s <= '9')
 72e:	00054683          	lbu	a3,0(a0)
 732:	fd06879b          	addiw	a5,a3,-48
 736:	0ff7f793          	zext.b	a5,a5
 73a:	4625                	li	a2,9
 73c:	02f66863          	bltu	a2,a5,76c <atoi+0x44>
 740:	872a                	mv	a4,a0
  n = 0;
 742:	4501                	li	a0,0
    n = n*10 + *s++ - '0';
 744:	0705                	addi	a4,a4,1
 746:	0025179b          	slliw	a5,a0,0x2
 74a:	9fa9                	addw	a5,a5,a0
 74c:	0017979b          	slliw	a5,a5,0x1
 750:	9fb5                	addw	a5,a5,a3
 752:	fd07851b          	addiw	a0,a5,-48
  while('0' <= *s && *s <= '9')
 756:	00074683          	lbu	a3,0(a4)
 75a:	fd06879b          	addiw	a5,a3,-48
 75e:	0ff7f793          	zext.b	a5,a5
 762:	fef671e3          	bgeu	a2,a5,744 <atoi+0x1c>
  return n;
}
 766:	6422                	ld	s0,8(sp)
 768:	0141                	addi	sp,sp,16
 76a:	8082                	ret
  n = 0;
 76c:	4501                	li	a0,0
 76e:	bfe5                	j	766 <atoi+0x3e>

0000000000000770 <memmove>:

void*
memmove(void *vdst, const void *vsrc, int n)
{
 770:	1141                	addi	sp,sp,-16
 772:	e422                	sd	s0,8(sp)
 774:	0800                	addi	s0,sp,16
  char *dst;
  const char *src;

  dst = vdst;
  src = vsrc;
  if (src > dst) {
 776:	02b57463          	bgeu	a0,a1,79e <memmove+0x2e>
    while(n-- > 0)
 77a:	00c05f63          	blez	a2,798 <memmove+0x28>
 77e:	1602                	slli	a2,a2,0x20
 780:	9201                	srli	a2,a2,0x20
 782:	00c507b3          	add	a5,a0,a2
  dst = vdst;
 786:	872a                	mv	a4,a0
      *dst++ = *src++;
 788:	0585                	addi	a1,a1,1
 78a:	0705                	addi	a4,a4,1
 78c:	fff5c683          	lbu	a3,-1(a1)
 790:	fed70fa3          	sb	a3,-1(a4)
    while(n-- > 0)
 794:	fee79ae3          	bne	a5,a4,788 <memmove+0x18>
    src += n;
    while(n-- > 0)
      *--dst = *--src;
  }
  return vdst;
}
 798:	6422                	ld	s0,8(sp)
 79a:	0141                	addi	sp,sp,16
 79c:	8082                	ret
    dst += n;
 79e:	00c50733          	add	a4,a0,a2
    src += n;
 7a2:	95b2                	add	a1,a1,a2
    while(n-- > 0)
 7a4:	fec05ae3          	blez	a2,798 <memmove+0x28>
 7a8:	fff6079b          	addiw	a5,a2,-1
 7ac:	1782                	slli	a5,a5,0x20
 7ae:	9381                	srli	a5,a5,0x20
 7b0:	fff7c793          	not	a5,a5
 7b4:	97ba                	add	a5,a5,a4
      *--dst = *--src;
 7b6:	15fd                	addi	a1,a1,-1
 7b8:	177d                	addi	a4,a4,-1
 7ba:	0005c683          	lbu	a3,0(a1)
 7be:	00d70023          	sb	a3,0(a4)
    while(n-- > 0)
 7c2:	fee79ae3          	bne	a5,a4,7b6 <memmove+0x46>
 7c6:	bfc9                	j	798 <memmove+0x28>

00000000000007c8 <memcmp>:

int
memcmp(const void *s1, const void *s2, uint n)
{
 7c8:	1141                	addi	sp,sp,-16
 7ca:	e422                	sd	s0,8(sp)
 7cc:	0800                	addi	s0,sp,16
  const char *p1 = s1, *p2 = s2;
  while (n-- > 0) {
 7ce:	ca05                	beqz	a2,7fe <memcmp+0x36>
 7d0:	fff6069b          	addiw	a3,a2,-1
 7d4:	1682                	slli	a3,a3,0x20
 7d6:	9281                	srli	a3,a3,0x20
 7d8:	0685                	addi	a3,a3,1
 7da:	96aa                	add	a3,a3,a0
    if (*p1 != *p2) {
 7dc:	00054783          	lbu	a5,0(a0)
 7e0:	0005c703          	lbu	a4,0(a1)
 7e4:	00e79863          	bne	a5,a4,7f4 <memcmp+0x2c>
      return *p1 - *p2;
    }
    p1++;
 7e8:	0505                	addi	a0,a0,1
    p2++;
 7ea:	0585                	addi	a1,a1,1
  while (n-- > 0) {
 7ec:	fed518e3          	bne	a0,a3,7dc <memcmp+0x14>
  }
  return 0;
 7f0:	4501                	li	a0,0
 7f2:	a019                	j	7f8 <memcmp+0x30>
      return *p1 - *p2;
 7f4:	40e7853b          	subw	a0,a5,a4
}
 7f8:	6422                	ld	s0,8(sp)
 7fa:	0141                	addi	sp,sp,16
 7fc:	8082                	ret
  return 0;
 7fe:	4501                	li	a0,0
 800:	bfe5                	j	7f8 <memcmp+0x30>

0000000000000802 <memcpy>:

void *
memcpy(void *dst, const void *src, uint n)
{
 802:	1141                	addi	sp,sp,-16
 804:	e406                	sd	ra,8(sp)
 806:	e022                	sd	s0,0(sp)
 808:	0800                	addi	s0,sp,16
  return memmove(dst, src, n);
 80a:	00000097          	auipc	ra,0x0
 80e:	f66080e7          	jalr	-154(ra) # 770 <memmove>
}
 812:	60a2                	ld	ra,8(sp)
 814:	6402                	ld	s0,0(sp)
 816:	0141                	addi	sp,sp,16
 818:	8082                	ret

000000000000081a <fork>:
# generated by usys.pl - do not edit
#include "kernel/syscall.h"
.global fork
fork:
 li a7, SYS_fork
 81a:	4885                	li	a7,1
 ecall
 81c:	00000073          	ecall
 ret
 820:	8082                	ret

0000000000000822 <exit>:
.global exit
exit:
 li a7, SYS_exit
 822:	4889                	li	a7,2
 ecall
 824:	00000073          	ecall
 ret
 828:	8082                	ret

000000000000082a <wait>:
.global wait
wait:
 li a7, SYS_wait
 82a:	488d                	li	a7,3
 ecall
 82c:	00000073          	ecall
 ret
 830:	8082                	ret

0000000000000832 <pipe>:
.global pipe
pipe:
 li a7, SYS_pipe
 832:	4891                	li	a7,4
 ecall
 834:	00000073          	ecall
 ret
 838:	8082                	ret

000000000000083a <read>:
.global read
read:
 li a7, SYS_read
 83a:	4895                	li	a7,5
 ecall
 83c:	00000073          	ecall
 ret
 840:	8082                	ret

0000000000000842 <write>:
.global write
write:
 li a7, SYS_write
 842:	48c1                	li	a7,16
 ecall
 844:	00000073          	ecall
 ret
 848:	8082                	ret

000000000000084a <close>:
.global close
close:
 li a7, SYS_close
 84a:	48d5                	li	a7,21
 ecall
 84c:	00000073          	ecall
 ret
 850:	8082                	ret

0000000000000852 <kill>:
.global kill
kill:
 li a7, SYS_kill
 852:	4899                	li	a7,6
 ecall
 854:	00000073          	ecall
 ret
 858:	8082                	ret

000000000000085a <exec>:
.global exec
exec:
 li a7, SYS_exec
 85a:	489d                	li	a7,7
 ecall
 85c:	00000073          	ecall
 ret
 860:	8082                	ret

0000000000000862 <open>:
.global open
open:
 li a7, SYS_open
 862:	48bd                	li	a7,15
 ecall
 864:	00000073          	ecall
 ret
 868:	8082                	ret

000000000000086a <mknod>:
.global mknod
mknod:
 li a7, SYS_mknod
 86a:	48c5                	li	a7,17
 ecall
 86c:	00000073          	ecall
 ret
 870:	8082                	ret

0000000000000872 <unlink>:
.global unlink
unlink:
 li a7, SYS_unlink
 872:	48c9                	li	a7,18
 ecall
 874:	00000073          	ecall
 ret
 878:	8082                	ret

000000000000087a <fstat>:
.global fstat
fstat:
 li a7, SYS_fstat
 87a:	48a1                	li	a7,8
 ecall
 87c:	00000073          	ecall
 ret
 880:	8082                	ret

0000000000000882 <link>:
.global link
link:
 li a7, SYS_link
 882:	48cd                	li	a7,19
 ecall
 884:	00000073          	ecall
 ret
 888:	8082                	ret

000000000000088a <mkdir>:
.global mkdir
mkdir:
 li a7, SYS_mkdir
 88a:	48d1                	li	a7,20
 ecall
 88c:	00000073          	ecall
 ret
 890:	8082                	ret

0000000000000892 <chdir>:
.global chdir
chdir:
 li a7, SYS_chdir
 892:	48a5                	li	a7,9
 ecall
 894:	00000073          	ecall
 ret
 898:	8082                	ret

000000000000089a <dup>:
.global dup
dup:
 li a7, SYS_dup
 89a:	48a9                	li	a7,10
 ecall
 89c:	00000073          	ecall
 ret
 8a0:	8082                	ret

00000000000008a2 <getpid>:
.global getpid
getpid:
 li a7, SYS_getpid
 8a2:	48ad                	li	a7,11
 ecall
 8a4:	00000073          	ecall
 ret
 8a8:	8082                	ret

00000000000008aa <sbrk>:
.global sbrk
sbrk:
 li a7, SYS_sbrk
 8aa:	48b1                	li	a7,12
 ecall
 8ac:	00000073          	ecall
 ret
 8b0:	8082                	ret

00000000000008b2 <sleep>:
.global sleep
sleep:
 li a7, SYS_sleep
 8b2:	48b5                	li	a7,13
 ecall
 8b4:	00000073          	ecall
 ret
 8b8:	8082                	ret

00000000000008ba <uptime>:
.global uptime
uptime:
 li a7, SYS_uptime
 8ba:	48b9                	li	a7,14
 ecall
 8bc:	00000073          	ecall
 ret
 8c0:	8082                	ret

00000000000008c2 <rbtn>:
.global rbtn
rbtn:
 li a7, SYS_rbtn
 8c2:	48d9                	li	a7,22
 ecall
 8c4:	00000073          	ecall
 ret
 8c8:	8082                	ret

00000000000008ca <putc>:

static char digits[] = "0123456789ABCDEF";

static void
putc(int fd, char c)
{
 8ca:	1101                	addi	sp,sp,-32
 8cc:	ec06                	sd	ra,24(sp)
 8ce:	e822                	sd	s0,16(sp)
 8d0:	1000                	addi	s0,sp,32
 8d2:	feb407a3          	sb	a1,-17(s0)
  write(fd, &c, 1);
 8d6:	4605                	li	a2,1
 8d8:	fef40593          	addi	a1,s0,-17
 8dc:	00000097          	auipc	ra,0x0
 8e0:	f66080e7          	jalr	-154(ra) # 842 <write>
}
 8e4:	60e2                	ld	ra,24(sp)
 8e6:	6442                	ld	s0,16(sp)
 8e8:	6105                	addi	sp,sp,32
 8ea:	8082                	ret

00000000000008ec <printint>:

static void
printint(int fd, int xx, int base, int sgn)
{
 8ec:	7139                	addi	sp,sp,-64
 8ee:	fc06                	sd	ra,56(sp)
 8f0:	f822                	sd	s0,48(sp)
 8f2:	f426                	sd	s1,40(sp)
 8f4:	f04a                	sd	s2,32(sp)
 8f6:	ec4e                	sd	s3,24(sp)
 8f8:	0080                	addi	s0,sp,64
 8fa:	84aa                	mv	s1,a0
  char buf[16];
  int i, neg;
  uint x;

  neg = 0;
  if(sgn && xx < 0){
 8fc:	c299                	beqz	a3,902 <printint+0x16>
 8fe:	0805c963          	bltz	a1,990 <printint+0xa4>
    neg = 1;
    x = -xx;
  } else {
    x = xx;
 902:	2581                	sext.w	a1,a1
  neg = 0;
 904:	4881                	li	a7,0
 906:	fc040693          	addi	a3,s0,-64
  }

  i = 0;
 90a:	4701                	li	a4,0
  do{
    buf[i++] = digits[x % base];
 90c:	2601                	sext.w	a2,a2
 90e:	00000517          	auipc	a0,0x0
 912:	6a250513          	addi	a0,a0,1698 # fb0 <digits>
 916:	883a                	mv	a6,a4
 918:	2705                	addiw	a4,a4,1
 91a:	02c5f7bb          	remuw	a5,a1,a2
 91e:	1782                	slli	a5,a5,0x20
 920:	9381                	srli	a5,a5,0x20
 922:	97aa                	add	a5,a5,a0
 924:	0007c783          	lbu	a5,0(a5)
 928:	00f68023          	sb	a5,0(a3)
  }while((x /= base) != 0);
 92c:	0005879b          	sext.w	a5,a1
 930:	02c5d5bb          	divuw	a1,a1,a2
 934:	0685                	addi	a3,a3,1
 936:	fec7f0e3          	bgeu	a5,a2,916 <printint+0x2a>
  if(neg)
 93a:	00088c63          	beqz	a7,952 <printint+0x66>
    buf[i++] = '-';
 93e:	fd070793          	addi	a5,a4,-48
 942:	00878733          	add	a4,a5,s0
 946:	02d00793          	li	a5,45
 94a:	fef70823          	sb	a5,-16(a4)
 94e:	0028071b          	addiw	a4,a6,2

  while(--i >= 0)
 952:	02e05863          	blez	a4,982 <printint+0x96>
 956:	fc040793          	addi	a5,s0,-64
 95a:	00e78933          	add	s2,a5,a4
 95e:	fff78993          	addi	s3,a5,-1
 962:	99ba                	add	s3,s3,a4
 964:	377d                	addiw	a4,a4,-1
 966:	1702                	slli	a4,a4,0x20
 968:	9301                	srli	a4,a4,0x20
 96a:	40e989b3          	sub	s3,s3,a4
    putc(fd, buf[i]);
 96e:	fff94583          	lbu	a1,-1(s2)
 972:	8526                	mv	a0,s1
 974:	00000097          	auipc	ra,0x0
 978:	f56080e7          	jalr	-170(ra) # 8ca <putc>
  while(--i >= 0)
 97c:	197d                	addi	s2,s2,-1
 97e:	ff3918e3          	bne	s2,s3,96e <printint+0x82>
}
 982:	70e2                	ld	ra,56(sp)
 984:	7442                	ld	s0,48(sp)
 986:	74a2                	ld	s1,40(sp)
 988:	7902                	ld	s2,32(sp)
 98a:	69e2                	ld	s3,24(sp)
 98c:	6121                	addi	sp,sp,64
 98e:	8082                	ret
    x = -xx;
 990:	40b005bb          	negw	a1,a1
    neg = 1;
 994:	4885                	li	a7,1
    x = -xx;
 996:	bf85                	j	906 <printint+0x1a>

0000000000000998 <vprintf>:
}

// Print to the given fd. Only understands %d, %x, %p, %s.
void
vprintf(int fd, const char *fmt, va_list ap)
{
 998:	7119                	addi	sp,sp,-128
 99a:	fc86                	sd	ra,120(sp)
 99c:	f8a2                	sd	s0,112(sp)
 99e:	f4a6                	sd	s1,104(sp)
 9a0:	f0ca                	sd	s2,96(sp)
 9a2:	ecce                	sd	s3,88(sp)
 9a4:	e8d2                	sd	s4,80(sp)
 9a6:	e4d6                	sd	s5,72(sp)
 9a8:	e0da                	sd	s6,64(sp)
 9aa:	fc5e                	sd	s7,56(sp)
 9ac:	f862                	sd	s8,48(sp)
 9ae:	f466                	sd	s9,40(sp)
 9b0:	f06a                	sd	s10,32(sp)
 9b2:	ec6e                	sd	s11,24(sp)
 9b4:	0100                	addi	s0,sp,128
  char *s;
  int c, i, state;

  state = 0;
  for(i = 0; fmt[i]; i++){
 9b6:	0005c903          	lbu	s2,0(a1)
 9ba:	18090f63          	beqz	s2,b58 <vprintf+0x1c0>
 9be:	8aaa                	mv	s5,a0
 9c0:	8b32                	mv	s6,a2
 9c2:	00158493          	addi	s1,a1,1
  state = 0;
 9c6:	4981                	li	s3,0
      if(c == '%'){
        state = '%';
      } else {
        putc(fd, c);
      }
    } else if(state == '%'){
 9c8:	02500a13          	li	s4,37
 9cc:	4c55                	li	s8,21
 9ce:	00000c97          	auipc	s9,0x0
 9d2:	58ac8c93          	addi	s9,s9,1418 # f58 <malloc+0x2fc>
        printptr(fd, va_arg(ap, uint64));
      } else if(c == 's'){
        s = va_arg(ap, char*);
        if(s == 0)
          s = "(null)";
        while(*s != 0){
 9d6:	02800d93          	li	s11,40
  putc(fd, 'x');
 9da:	4d41                	li	s10,16
    putc(fd, digits[x >> (sizeof(uint64) * 8 - 4)]);
 9dc:	00000b97          	auipc	s7,0x0
 9e0:	5d4b8b93          	addi	s7,s7,1492 # fb0 <digits>
 9e4:	a839                	j	a02 <vprintf+0x6a>
        putc(fd, c);
 9e6:	85ca                	mv	a1,s2
 9e8:	8556                	mv	a0,s5
 9ea:	00000097          	auipc	ra,0x0
 9ee:	ee0080e7          	jalr	-288(ra) # 8ca <putc>
 9f2:	a019                	j	9f8 <vprintf+0x60>
    } else if(state == '%'){
 9f4:	01498d63          	beq	s3,s4,a0e <vprintf+0x76>
  for(i = 0; fmt[i]; i++){
 9f8:	0485                	addi	s1,s1,1
 9fa:	fff4c903          	lbu	s2,-1(s1)
 9fe:	14090d63          	beqz	s2,b58 <vprintf+0x1c0>
    if(state == 0){
 a02:	fe0999e3          	bnez	s3,9f4 <vprintf+0x5c>
      if(c == '%'){
 a06:	ff4910e3          	bne	s2,s4,9e6 <vprintf+0x4e>
        state = '%';
 a0a:	89d2                	mv	s3,s4
 a0c:	b7f5                	j	9f8 <vprintf+0x60>
      if(c == 'd'){
 a0e:	11490c63          	beq	s2,s4,b26 <vprintf+0x18e>
 a12:	f9d9079b          	addiw	a5,s2,-99
 a16:	0ff7f793          	zext.b	a5,a5
 a1a:	10fc6e63          	bltu	s8,a5,b36 <vprintf+0x19e>
 a1e:	f9d9079b          	addiw	a5,s2,-99
 a22:	0ff7f713          	zext.b	a4,a5
 a26:	10ec6863          	bltu	s8,a4,b36 <vprintf+0x19e>
 a2a:	00271793          	slli	a5,a4,0x2
 a2e:	97e6                	add	a5,a5,s9
 a30:	439c                	lw	a5,0(a5)
 a32:	97e6                	add	a5,a5,s9
 a34:	8782                	jr	a5
        printint(fd, va_arg(ap, int), 10, 1);
 a36:	008b0913          	addi	s2,s6,8
 a3a:	4685                	li	a3,1
 a3c:	4629                	li	a2,10
 a3e:	000b2583          	lw	a1,0(s6)
 a42:	8556                	mv	a0,s5
 a44:	00000097          	auipc	ra,0x0
 a48:	ea8080e7          	jalr	-344(ra) # 8ec <printint>
 a4c:	8b4a                	mv	s6,s2
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
        putc(fd, c);
      }
      state = 0;
 a4e:	4981                	li	s3,0
 a50:	b765                	j	9f8 <vprintf+0x60>
        printint(fd, va_arg(ap, uint64), 10, 0);
 a52:	008b0913          	addi	s2,s6,8
 a56:	4681                	li	a3,0
 a58:	4629                	li	a2,10
 a5a:	000b2583          	lw	a1,0(s6)
 a5e:	8556                	mv	a0,s5
 a60:	00000097          	auipc	ra,0x0
 a64:	e8c080e7          	jalr	-372(ra) # 8ec <printint>
 a68:	8b4a                	mv	s6,s2
      state = 0;
 a6a:	4981                	li	s3,0
 a6c:	b771                	j	9f8 <vprintf+0x60>
        printint(fd, va_arg(ap, int), 16, 0);
 a6e:	008b0913          	addi	s2,s6,8
 a72:	4681                	li	a3,0
 a74:	866a                	mv	a2,s10
 a76:	000b2583          	lw	a1,0(s6)
 a7a:	8556                	mv	a0,s5
 a7c:	00000097          	auipc	ra,0x0
 a80:	e70080e7          	jalr	-400(ra) # 8ec <printint>
 a84:	8b4a                	mv	s6,s2
      state = 0;
 a86:	4981                	li	s3,0
 a88:	bf85                	j	9f8 <vprintf+0x60>
        printptr(fd, va_arg(ap, uint64));
 a8a:	008b0793          	addi	a5,s6,8
 a8e:	f8f43423          	sd	a5,-120(s0)
 a92:	000b3983          	ld	s3,0(s6)
  putc(fd, '0');
 a96:	03000593          	li	a1,48
 a9a:	8556                	mv	a0,s5
 a9c:	00000097          	auipc	ra,0x0
 aa0:	e2e080e7          	jalr	-466(ra) # 8ca <putc>
  putc(fd, 'x');
 aa4:	07800593          	li	a1,120
 aa8:	8556                	mv	a0,s5
 aaa:	00000097          	auipc	ra,0x0
 aae:	e20080e7          	jalr	-480(ra) # 8ca <putc>
 ab2:	896a                	mv	s2,s10
    putc(fd, digits[x >> (sizeof(uint64) * 8 - 4)]);
 ab4:	03c9d793          	srli	a5,s3,0x3c
 ab8:	97de                	add	a5,a5,s7
 aba:	0007c583          	lbu	a1,0(a5)
 abe:	8556                	mv	a0,s5
 ac0:	00000097          	auipc	ra,0x0
 ac4:	e0a080e7          	jalr	-502(ra) # 8ca <putc>
  for (i = 0; i < (sizeof(uint64) * 2); i++, x <<= 4)
 ac8:	0992                	slli	s3,s3,0x4
 aca:	397d                	addiw	s2,s2,-1
 acc:	fe0914e3          	bnez	s2,ab4 <vprintf+0x11c>
        printptr(fd, va_arg(ap, uint64));
 ad0:	f8843b03          	ld	s6,-120(s0)
      state = 0;
 ad4:	4981                	li	s3,0
 ad6:	b70d                	j	9f8 <vprintf+0x60>
        s = va_arg(ap, char*);
 ad8:	008b0913          	addi	s2,s6,8
 adc:	000b3983          	ld	s3,0(s6)
        if(s == 0)
 ae0:	02098163          	beqz	s3,b02 <vprintf+0x16a>
        while(*s != 0){
 ae4:	0009c583          	lbu	a1,0(s3)
 ae8:	c5ad                	beqz	a1,b52 <vprintf+0x1ba>
          putc(fd, *s);
 aea:	8556                	mv	a0,s5
 aec:	00000097          	auipc	ra,0x0
 af0:	dde080e7          	jalr	-546(ra) # 8ca <putc>
          s++;
 af4:	0985                	addi	s3,s3,1
        while(*s != 0){
 af6:	0009c583          	lbu	a1,0(s3)
 afa:	f9e5                	bnez	a1,aea <vprintf+0x152>
        s = va_arg(ap, char*);
 afc:	8b4a                	mv	s6,s2
      state = 0;
 afe:	4981                	li	s3,0
 b00:	bde5                	j	9f8 <vprintf+0x60>
          s = "(null)";
 b02:	00000997          	auipc	s3,0x0
 b06:	44e98993          	addi	s3,s3,1102 # f50 <malloc+0x2f4>
        while(*s != 0){
 b0a:	85ee                	mv	a1,s11
 b0c:	bff9                	j	aea <vprintf+0x152>
        putc(fd, va_arg(ap, uint));
 b0e:	008b0913          	addi	s2,s6,8
 b12:	000b4583          	lbu	a1,0(s6)
 b16:	8556                	mv	a0,s5
 b18:	00000097          	auipc	ra,0x0
 b1c:	db2080e7          	jalr	-590(ra) # 8ca <putc>
 b20:	8b4a                	mv	s6,s2
      state = 0;
 b22:	4981                	li	s3,0
 b24:	bdd1                	j	9f8 <vprintf+0x60>
        putc(fd, c);
 b26:	85d2                	mv	a1,s4
 b28:	8556                	mv	a0,s5
 b2a:	00000097          	auipc	ra,0x0
 b2e:	da0080e7          	jalr	-608(ra) # 8ca <putc>
      state = 0;
 b32:	4981                	li	s3,0
 b34:	b5d1                	j	9f8 <vprintf+0x60>
        putc(fd, '%');
 b36:	85d2                	mv	a1,s4
 b38:	8556                	mv	a0,s5
 b3a:	00000097          	auipc	ra,0x0
 b3e:	d90080e7          	jalr	-624(ra) # 8ca <putc>
        putc(fd, c);
 b42:	85ca                	mv	a1,s2
 b44:	8556                	mv	a0,s5
 b46:	00000097          	auipc	ra,0x0
 b4a:	d84080e7          	jalr	-636(ra) # 8ca <putc>
      state = 0;
 b4e:	4981                	li	s3,0
 b50:	b565                	j	9f8 <vprintf+0x60>
        s = va_arg(ap, char*);
 b52:	8b4a                	mv	s6,s2
      state = 0;
 b54:	4981                	li	s3,0
 b56:	b54d                	j	9f8 <vprintf+0x60>
    }
  }
}
 b58:	70e6                	ld	ra,120(sp)
 b5a:	7446                	ld	s0,112(sp)
 b5c:	74a6                	ld	s1,104(sp)
 b5e:	7906                	ld	s2,96(sp)
 b60:	69e6                	ld	s3,88(sp)
 b62:	6a46                	ld	s4,80(sp)
 b64:	6aa6                	ld	s5,72(sp)
 b66:	6b06                	ld	s6,64(sp)
 b68:	7be2                	ld	s7,56(sp)
 b6a:	7c42                	ld	s8,48(sp)
 b6c:	7ca2                	ld	s9,40(sp)
 b6e:	7d02                	ld	s10,32(sp)
 b70:	6de2                	ld	s11,24(sp)
 b72:	6109                	addi	sp,sp,128
 b74:	8082                	ret

0000000000000b76 <fprintf>:

void
fprintf(int fd, const char *fmt, ...)
{
 b76:	715d                	addi	sp,sp,-80
 b78:	ec06                	sd	ra,24(sp)
 b7a:	e822                	sd	s0,16(sp)
 b7c:	1000                	addi	s0,sp,32
 b7e:	e010                	sd	a2,0(s0)
 b80:	e414                	sd	a3,8(s0)
 b82:	e818                	sd	a4,16(s0)
 b84:	ec1c                	sd	a5,24(s0)
 b86:	03043023          	sd	a6,32(s0)
 b8a:	03143423          	sd	a7,40(s0)
  va_list ap;

  va_start(ap, fmt);
 b8e:	fe843423          	sd	s0,-24(s0)
  vprintf(fd, fmt, ap);
 b92:	8622                	mv	a2,s0
 b94:	00000097          	auipc	ra,0x0
 b98:	e04080e7          	jalr	-508(ra) # 998 <vprintf>
}
 b9c:	60e2                	ld	ra,24(sp)
 b9e:	6442                	ld	s0,16(sp)
 ba0:	6161                	addi	sp,sp,80
 ba2:	8082                	ret

0000000000000ba4 <printf>:

void
printf(const char *fmt, ...)
{
 ba4:	711d                	addi	sp,sp,-96
 ba6:	ec06                	sd	ra,24(sp)
 ba8:	e822                	sd	s0,16(sp)
 baa:	1000                	addi	s0,sp,32
 bac:	e40c                	sd	a1,8(s0)
 bae:	e810                	sd	a2,16(s0)
 bb0:	ec14                	sd	a3,24(s0)
 bb2:	f018                	sd	a4,32(s0)
 bb4:	f41c                	sd	a5,40(s0)
 bb6:	03043823          	sd	a6,48(s0)
 bba:	03143c23          	sd	a7,56(s0)
  va_list ap;

  va_start(ap, fmt);
 bbe:	00840613          	addi	a2,s0,8
 bc2:	fec43423          	sd	a2,-24(s0)
  vprintf(1, fmt, ap);
 bc6:	85aa                	mv	a1,a0
 bc8:	4505                	li	a0,1
 bca:	00000097          	auipc	ra,0x0
 bce:	dce080e7          	jalr	-562(ra) # 998 <vprintf>
}
 bd2:	60e2                	ld	ra,24(sp)
 bd4:	6442                	ld	s0,16(sp)
 bd6:	6125                	addi	sp,sp,96
 bd8:	8082                	ret

0000000000000bda <free>:
static Header base;
static Header *freep;

void
free(void *ap)
{
 bda:	1141                	addi	sp,sp,-16
 bdc:	e422                	sd	s0,8(sp)
 bde:	0800                	addi	s0,sp,16
  Header *bp, *p;

  bp = (Header*)ap - 1;
 be0:	ff050693          	addi	a3,a0,-16
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
 be4:	00000797          	auipc	a5,0x0
 be8:	3e47b783          	ld	a5,996(a5) # fc8 <freep>
 bec:	a02d                	j	c16 <free+0x3c>
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
      break;
  if(bp + bp->s.size == p->s.ptr){
    bp->s.size += p->s.ptr->s.size;
 bee:	4618                	lw	a4,8(a2)
 bf0:	9f2d                	addw	a4,a4,a1
 bf2:	fee52c23          	sw	a4,-8(a0)
    bp->s.ptr = p->s.ptr->s.ptr;
 bf6:	6398                	ld	a4,0(a5)
 bf8:	6310                	ld	a2,0(a4)
 bfa:	a83d                	j	c38 <free+0x5e>
  } else
    bp->s.ptr = p->s.ptr;
  if(p + p->s.size == bp){
    p->s.size += bp->s.size;
 bfc:	ff852703          	lw	a4,-8(a0)
 c00:	9f31                	addw	a4,a4,a2
 c02:	c798                	sw	a4,8(a5)
    p->s.ptr = bp->s.ptr;
 c04:	ff053683          	ld	a3,-16(a0)
 c08:	a091                	j	c4c <free+0x72>
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
 c0a:	6398                	ld	a4,0(a5)
 c0c:	00e7e463          	bltu	a5,a4,c14 <free+0x3a>
 c10:	00e6ea63          	bltu	a3,a4,c24 <free+0x4a>
{
 c14:	87ba                	mv	a5,a4
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
 c16:	fed7fae3          	bgeu	a5,a3,c0a <free+0x30>
 c1a:	6398                	ld	a4,0(a5)
 c1c:	00e6e463          	bltu	a3,a4,c24 <free+0x4a>
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
 c20:	fee7eae3          	bltu	a5,a4,c14 <free+0x3a>
  if(bp + bp->s.size == p->s.ptr){
 c24:	ff852583          	lw	a1,-8(a0)
 c28:	6390                	ld	a2,0(a5)
 c2a:	02059813          	slli	a6,a1,0x20
 c2e:	01c85713          	srli	a4,a6,0x1c
 c32:	9736                	add	a4,a4,a3
 c34:	fae60de3          	beq	a2,a4,bee <free+0x14>
    bp->s.ptr = p->s.ptr->s.ptr;
 c38:	fec53823          	sd	a2,-16(a0)
  if(p + p->s.size == bp){
 c3c:	4790                	lw	a2,8(a5)
 c3e:	02061593          	slli	a1,a2,0x20
 c42:	01c5d713          	srli	a4,a1,0x1c
 c46:	973e                	add	a4,a4,a5
 c48:	fae68ae3          	beq	a3,a4,bfc <free+0x22>
    p->s.ptr = bp->s.ptr;
 c4c:	e394                	sd	a3,0(a5)
  } else
    p->s.ptr = bp;
  freep = p;
 c4e:	00000717          	auipc	a4,0x0
 c52:	36f73d23          	sd	a5,890(a4) # fc8 <freep>
}
 c56:	6422                	ld	s0,8(sp)
 c58:	0141                	addi	sp,sp,16
 c5a:	8082                	ret

0000000000000c5c <malloc>:
  return freep;
}

void*
malloc(uint nbytes)
{
 c5c:	7139                	addi	sp,sp,-64
 c5e:	fc06                	sd	ra,56(sp)
 c60:	f822                	sd	s0,48(sp)
 c62:	f426                	sd	s1,40(sp)
 c64:	f04a                	sd	s2,32(sp)
 c66:	ec4e                	sd	s3,24(sp)
 c68:	e852                	sd	s4,16(sp)
 c6a:	e456                	sd	s5,8(sp)
 c6c:	e05a                	sd	s6,0(sp)
 c6e:	0080                	addi	s0,sp,64
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
 c70:	02051493          	slli	s1,a0,0x20
 c74:	9081                	srli	s1,s1,0x20
 c76:	04bd                	addi	s1,s1,15
 c78:	8091                	srli	s1,s1,0x4
 c7a:	0014899b          	addiw	s3,s1,1
 c7e:	0485                	addi	s1,s1,1
  if((prevp = freep) == 0){
 c80:	00000517          	auipc	a0,0x0
 c84:	34853503          	ld	a0,840(a0) # fc8 <freep>
 c88:	c515                	beqz	a0,cb4 <malloc+0x58>
    base.s.ptr = freep = prevp = &base;
    base.s.size = 0;
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
 c8a:	611c                	ld	a5,0(a0)
    if(p->s.size >= nunits){
 c8c:	4798                	lw	a4,8(a5)
 c8e:	02977f63          	bgeu	a4,s1,ccc <malloc+0x70>
 c92:	8a4e                	mv	s4,s3
 c94:	0009871b          	sext.w	a4,s3
 c98:	6685                	lui	a3,0x1
 c9a:	00d77363          	bgeu	a4,a3,ca0 <malloc+0x44>
 c9e:	6a05                	lui	s4,0x1
 ca0:	000a0b1b          	sext.w	s6,s4
  p = sbrk(nu * sizeof(Header));
 ca4:	004a1a1b          	slliw	s4,s4,0x4
        p->s.size = nunits;
      }
      freep = prevp;
      return (void*)(p + 1);
    }
    if(p == freep)
 ca8:	00000917          	auipc	s2,0x0
 cac:	32090913          	addi	s2,s2,800 # fc8 <freep>
  if(p == (char*)-1)
 cb0:	5afd                	li	s5,-1
 cb2:	a895                	j	d26 <malloc+0xca>
    base.s.ptr = freep = prevp = &base;
 cb4:	00000797          	auipc	a5,0x0
 cb8:	31c78793          	addi	a5,a5,796 # fd0 <base>
 cbc:	00000717          	auipc	a4,0x0
 cc0:	30f73623          	sd	a5,780(a4) # fc8 <freep>
 cc4:	e39c                	sd	a5,0(a5)
    base.s.size = 0;
 cc6:	0007a423          	sw	zero,8(a5)
    if(p->s.size >= nunits){
 cca:	b7e1                	j	c92 <malloc+0x36>
      if(p->s.size == nunits)
 ccc:	02e48c63          	beq	s1,a4,d04 <malloc+0xa8>
        p->s.size -= nunits;
 cd0:	4137073b          	subw	a4,a4,s3
 cd4:	c798                	sw	a4,8(a5)
        p += p->s.size;
 cd6:	02071693          	slli	a3,a4,0x20
 cda:	01c6d713          	srli	a4,a3,0x1c
 cde:	97ba                	add	a5,a5,a4
        p->s.size = nunits;
 ce0:	0137a423          	sw	s3,8(a5)
      freep = prevp;
 ce4:	00000717          	auipc	a4,0x0
 ce8:	2ea73223          	sd	a0,740(a4) # fc8 <freep>
      return (void*)(p + 1);
 cec:	01078513          	addi	a0,a5,16
      if((p = morecore(nunits)) == 0)
        return 0;
  }
}
 cf0:	70e2                	ld	ra,56(sp)
 cf2:	7442                	ld	s0,48(sp)
 cf4:	74a2                	ld	s1,40(sp)
 cf6:	7902                	ld	s2,32(sp)
 cf8:	69e2                	ld	s3,24(sp)
 cfa:	6a42                	ld	s4,16(sp)
 cfc:	6aa2                	ld	s5,8(sp)
 cfe:	6b02                	ld	s6,0(sp)
 d00:	6121                	addi	sp,sp,64
 d02:	8082                	ret
        prevp->s.ptr = p->s.ptr;
 d04:	6398                	ld	a4,0(a5)
 d06:	e118                	sd	a4,0(a0)
 d08:	bff1                	j	ce4 <malloc+0x88>
  hp->s.size = nu;
 d0a:	01652423          	sw	s6,8(a0)
  free((void*)(hp + 1));
 d0e:	0541                	addi	a0,a0,16
 d10:	00000097          	auipc	ra,0x0
 d14:	eca080e7          	jalr	-310(ra) # bda <free>
  return freep;
 d18:	00093503          	ld	a0,0(s2)
      if((p = morecore(nunits)) == 0)
 d1c:	d971                	beqz	a0,cf0 <malloc+0x94>
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
 d1e:	611c                	ld	a5,0(a0)
    if(p->s.size >= nunits){
 d20:	4798                	lw	a4,8(a5)
 d22:	fa9775e3          	bgeu	a4,s1,ccc <malloc+0x70>
    if(p == freep)
 d26:	00093703          	ld	a4,0(s2)
 d2a:	853e                	mv	a0,a5
 d2c:	fef719e3          	bne	a4,a5,d1e <malloc+0xc2>
  p = sbrk(nu * sizeof(Header));
 d30:	8552                	mv	a0,s4
 d32:	00000097          	auipc	ra,0x0
 d36:	b78080e7          	jalr	-1160(ra) # 8aa <sbrk>
  if(p == (char*)-1)
 d3a:	fd5518e3          	bne	a0,s5,d0a <malloc+0xae>
        return 0;
 d3e:	4501                	li	a0,0
 d40:	bf45                	j	cf0 <malloc+0x94>
